/**
 * Javascript file
 *
 */

 $(function () {
	 $('#checkuser').click(function () {
		 var _login = $('#popin_login').val();
		 var _email  = $('#popin_email').val();
		 var _url   = "admin.php?module=admin&action=password:checkUser";
	
		 if (_email && _login && checkMail(_email))
		 {
		 
			 $.ajax({
			  type: "POST",
			  url: _url,
			  data: "&login="+_login+"&email="+_email,
			  success: function(msg){
				if (!msg)
				{
					$('#messageError').show();
					return false;
				}
				else
				{
					alert('Veuillez consulter votre boite aux lettres');
					
					$('.close').click();

				}
			  }
			});
		} else {
			$('#messageError').show();
			return false;
		}

	 });
 });

/**
 * Vérifie la syntaxe d'une adresse mail
 */
 function checkMail(_mail) {
	 var ret = true;
	 if (_mail.search(/^[a-z0-9._-]+@[a-z0-9._-]{2,}[.][a-z]{2,3}$/) == -1 ){
		 ret = false;
	 }
	 return ret;
 }